<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">


<ui:composition template="/templates/templateDiretor.xhtml">
	<ui:define name="conteudo">
		<h:form>

			<p:dataTable var="sala" id="listarsala" value="#{mBSala.salas}"
				emptyMessage="Não há salas cadastrados" rows="10"
				rendered="#{!mBSala.visualizar}" paginator="true">
				<p:column filterBy="#{sala.nome}" filterMatchMode="contains"
					headerText="Nome">
					<h:outputText value="#{sala.nome}" />
				</p:column>
				<p:column filterBy="#{sala.escola.nome}" filterMatchMode="contains"
					headerText="Nome">
					<h:outputText value="#{sala.escola.nome}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						Operações
					</f:facet>
					<p:commandButton value="Editar" ajax="false"
						action="#{mBSala.irEditar()}">
						<f:setPropertyActionListener target="#{mBSala.sala}"
							value="#{sala}" />
					</p:commandButton>
					<p:commandButton value="Excluir" oncomplete="confirmation.show()">
						<f:setPropertyActionListener target="#{mBSala.sala}"
							value="#{sala}" />
					</p:commandButton>


					<p:confirmDialog id="confirmDialog"
						message="Tem certeza que deseja excluir a sala?" header="Warning"
						severity="alert" widgetVar="confirmation">

						<p:commandButton id="confirm" value="Sim"
							oncomplete="confirmation.hide()" action="#{mBSala.remover()}"
							ajax="false" />

						<p:commandButton id="decline" value="Não"
							oncomplete="confirmation.hide()"
							action="#{mBSala.limpar}" />

					</p:confirmDialog>

				</p:column>
			</p:dataTable>
		</h:form>

		<h:form>
			<p:panel header="Sala" rendered="#{!mBSala.visualizar}">

				<h:panelGrid columns="2" id="painelgrid">
					<h:outputLabel value="Nome*:" />
					<p:inputText value="#{mBSala.sala.nome}" size="30" required="true" requiredMessage="Insira o nome"/>
					<h:outputLabel value="Vagas:" />
					<p:inputText value="#{mBSala.sala.vagas}" size="10" required="true" requiredMessage="Insira a quantidade de vagas"/>
					<p:commandButton rendered="#{!mBSala.editavel}" action="#{mBSala.cadastrar}" ajax="false" value="Cadastrar"/>
					<p:commandButton rendered="#{mBSala.editavel}" action="#{mBSala.editar}" ajax="false" value="Editar"/>
					<p:commandButton action="#{mBSala.limpar}" onclick="form.reset()" ajax="false" value="Cancelar"/>
				</h:panelGrid>
				
			</p:panel>
		</h:form>

	</ui:define>
</ui:composition>
</html>